package com.guavamail.smtp.command.impl;

import java.io.IOException;

import org.apache.mina.core.session.IoSession;

import com.guavamail.smtp.SMTPContext;
import com.guavamail.smtp.command.AbstractCommand;

public class HELO extends AbstractCommand {
	public HELO() {
		super("HELO", "");
	}

	@Override
	public void execute(String commandString, IoSession ioSession, SMTPContext ctx) throws IOException {
		String[] args = getArgs(commandString);
		if (args.length < 2) {
			sendResponse(ioSession, "501 Syntax: HELO <hostname>");
			return;
		}

		// 反向解析

		ctx.getSessionStatus().setHasSeenHelo(true);
		sendResponse(ioSession, "250 " + ctx.getSMTPServerConfig().getHostName());
	}

}
